const router = require('koa-router')();
const getReport = require('../../app/mws/reports/GetReport');

router.prefix('/api/v1/reports');
router.get('/', function (ctx, next) {
  ctx.body = 'this is a getReport response!'
});

router.get('/:reportId', async (ctx, next) => {
  const sellerId = ctx.headers.sellerid;
  const mwsAuthToken = ctx.headers.mwsauthtoken;
  const reportId = ctx.params.reportId;

  try {
    let json = await getReport.getReport(sellerId, mwsAuthToken, reportId);
    ctx.response.status = 200;
    ctx.response.body = {
      data: json,
    };
  } catch (error) {
    ctx.response.status = 500;
    ctx.response.body = {
      data: error,
    };
  }
});

module.exports = router;